/** * Copyright (c) 2016-2019 人人开源 All rights reserved. */

package com.joinval.modules.sys.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.joinval.modules.sys.dto.VolUserDTO;
import com.joinval.modules.sys.entity.SysUserEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 系统用户
 *
 * @author Mark sunlightcs@gmail.com
 */
@Mapper
public interface SysUserDao extends BaseMapper<SysUserEntity> {

	/**
	 * 查询用户的所有权限
	 * @param userId  用户ID
	 */
	List<String> queryAllPerms(Long userId);

	/**
	 * 查询用户的所有菜单ID
	 */
	List<Long> queryAllMenuId(Long userId);

	/**
	 * 查询用户的所有角色ID
	 */
	List<Long> queryAllRoleId(Long userId);

	/**
	 * 根据用户名，查询系统用户
	 */
	SysUserEntity queryByUserName(String username);

	/**
	 * 查询用户中心信息
	 * @param userId
	 * @return
	 */
    Map<String, Object> queryVolUserCenter(Long userId);

	/**
	 * 下拉菜单
	 * @param userType
	 * @return
	 */
	Page<Map<String, Object>> menuList(Page page,
									   @Param("userType")String userType,
									   @Param("orgAuditStatus")Integer orgAuditStatus,
									   @Param("volAuditStatus")Integer volAuditStatus,
									   @Param("orgCode")String orgCode,
									   @Param("volCode")String volCode,
									   @Param("orgName")String orgName,
									   @Param("realName")String realName,
									   @Param("mobile")String mobile);


	/**
	 * 登录用户信息
	 * @param userId
	 * @return
	 */
	Map<String, Object> loginUserInfo(Long userId);

	List<Map<String, Object>> getUserRolesByUserId(Long userId);

	/**
	 * 查询志愿者详情
	 * @param userId
	 * @return
	 */
	Map<String, Object> volUserInfo(Long userId);

	/**
	 * 查询点单机构详情
	 * @param userId
	 * @return
	 */
	Map<String, Object> volOrgInfo(Long userId);

	/**
	 * 后台用户详情
	 * @param userId
	 * @return
	 */
	Map<String, Object> bgUserInfo(Long userId);


	Page<Map<String, Object>> orgList(Page page, @Param("auditStatus")Integer auditStatus,
												  @Param("orgName")String orgName,
												  @Param("orgLocation")String orgLocation,
												  @Param("orgType")String orgType,
												  @Param("realName")String realName,
												  @Param("mobile")String mobile);

	Page<Map<String, Object>> volList(Page page, @Param("userIds")List<Long> userIds,
									  			  @Param("auditStatus")Integer auditStatus,
												  @Param("volCode")String volCode,
									              @Param("realName")String realName,
												  @Param("mobile")String mobile,
												  @Param("minServiceHour") Integer minServiceHour,
												  @Param("maxServiceHour") Integer maxServiceHour);

	Page<Map<String, Object>> list(Page page,@Param("status")Integer status,
											  @Param("gender")Integer gender,
											  @Param("idCard")String idCard,
											  @Param("username")String username,
											  @Param("realName")String realName,
											  @Param("mobile")String mobile,
			 								  @Param("townId")Long townId,
								              @Param("roleId")Long roleId,
											@Param("countyId") Long countyId,
											@Param("townIds") List<Long> townIds
	);


	Page<Map<String, Object>> getUserListPageByRoleCode(Page page,@Param("status")Integer status,
								   @Param("gender")Integer gender,
								   @Param("idCard")String idCard,
								   @Param("username")String username,
								   @Param("realName")String realName,
								   @Param("mobile")String mobile
			,@Param("roleCode")String roleCode
			,@Param("countyId")Long countyId
			,@Param("townId")Long townId
			,@Param("townIdList")List<Long> townIdList
	);




	/**
	 * 查询志愿者主键
	 * @return
	 */
	List<Long> getVolUserIdByAge(@Param("minAge") Integer minAge,
								 @Param("maxAge") Integer maxAge);

	int updateLogoById(@Param("logo")String logo,@Param("userId")Long userId);

	List<Map<String,Object>> queryPointExchangeRecordsByVolTeamId(@Param("volTeamId")Long volTeamId);

	Page<Map<String, Object>> queryPointExchangeRecordsPageByVolTeamId(Page page, @Param("volTeamId")Long volTeamId);

	VolUserDTO queryVolUser(@Param("idCard")String idCard,@Param("volCode")String volCode);
}
